package com.gjy.statemachine.controller;

import com.gjy.statemachine.module.TbOrder;
import com.gjy.statemachine.service.impl.OrderService2Impl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-07-02 14:50:37
 */
@RestController
@RequestMapping("/order")
public class Order2Controller {

    @Resource
    private OrderService2Impl orderService2;

    /**
     * 根据id查询订单
     */
    @PostMapping("/getById")
    public TbOrder getById(@RequestParam("id") Long id) {
        return orderService2.getById(id);
    }

    /**
     * 创建订单
     */
    @PostMapping("/create")
    public String create(@RequestBody TbOrder order) {
        //创建订单
        orderService2.create(order);
        return "sucess";
    }

    /**
     * 对订单进行支付
     */
    @PostMapping("/pay")
    public String pay(@RequestParam("id") Long id) {
        //对订单进行支付
        orderService2.pay(id);
        return "success";
    }

    /**
     * 对订单进行发货
     */
    @PostMapping("/deliver")
    public String deliver(@RequestParam("id") Long id) {
        //对订单进行确认收货
        orderService2.deliver(id);
        return "success";
    }

    /**
     * 对订单进行确认收货
     */
    @PostMapping("/receive")
    public String receive(@RequestParam("id") Long id) {
        //对订单进行确认收货
        orderService2.receive(id);
        return "success";
    }

}
